script(type='text/javascript')
	$("body").ready(function() {
		$("#editSave").hide();
		
		$("#editNameField").hide();
		$("#editName").click(function() {
			$("#editNameValue").hide();
			$("#editNameField").fadeIn('slow');
			$("#editNameField").focus();
			$("#editSave").fadeIn('slow');
		});
		
		$("#editLocationField").hide();
		$("#editLocation").click(function() {
			$("#editLocationValue").hide();
			$("#editLocationField").fadeIn('slow');
			$("#editLocationField").focus();
			$("#editSave").fadeIn('slow');
		});
		
		$("#editDescriptionField").hide();
		$("#editDescription").click(function() {
			$("#editDescriptionValue").hide();
			$("#editDescriptionField").fadeIn('slow');
			$("#editDescriptionField").focus();
			$("#editSave").fadeIn('slow');
		});
	});
form(
	method='post',
	action='/devices/'+device._id,
	enctype='application/x-www-form-urlencoded')
	table
		tr
			td.neutral(colspan='2')
				h3 Device Configuration
				input#editSave(type='submit',value='Save')
		tr
			td.neutral.editLabel Device Name
			td.neutral#editName
				#editNameValue= device.name
				input#editNameField(type='text',name='name',value=device.name)		
		tr
			-if(device.status == 'online')
				td.ok.editLabel Status
				td.ok= device.status
			-if(device.status == 'offline')
				td.error.editLabel Status
				td.error= device.status
			-if(device.status == 'noconf')
				td.warn.editLabel Status
				td.warn= device.status
		tr
			td.neutral.editLabel MAC Address
			td.neutral= device.hwAddress
		tr
			td.neutral.editLabel IP Address
			td.neutral= device.inetAddress
		tr
			td.neutral.editLabel Location
			td.neutral#editLocation
				#editLocationValue= device.location
				input#editLocationField(type='text',name='location',value=device.location)
		tr
			td.neutral.editLabel Description
			td.neutral#editDescription
				#editDescriptionValue= device.description
				input#editDescriptionField(type='text',name='description',value=device.description)
		tr
			td.neutral(colspan='2')
				h4 Ports
				input#editAddPort(
					type='button',
					value='Add Port',
					onclick='window.location=\'/ports/' + device.hwAddress + '\'')
				.list
					ul
						each port in ports
							li.neutral(onclick='window.location=\'/ports/' + port._id + '\'')= port.name

